/*
 * Copyright 2009 XueSong Guo.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cn.webwheel;

/**
 * WebWheel MVC框架的过滤器接口。<br>
 */
public interface Filter {
    /**
     * 初始化方法。
     * @throws Exception 初始化异常
     */
    void init() throws Exception;

    /**
     * 过滤方法。<br>
     * 在此方法的实现中，可通过返回true短路http请求，或通过返回false指示框架不处理此http请求，
     * 或通过返回{@link FilterChain#go()}的返回值使过滤器链继续执行。
     * @param chain 过滤器链对象
     * @return 程序是否已经处理了此次http请求。
     * @throws Exception 任何异常
     */
    boolean process(FilterChain chain) throws Exception;

    /**
     * 销毁方法。
     */
    void destroy();
}
